package com.xjm.i1.core.resolver.impl;

import com.xjm.i1.constant.AreaEnum;
import com.xjm.i1.constant.ColorEnum;
import com.xjm.i1.constant.MinDensityEnum;
import com.xjm.i1.core.resolver.AbstractColorDiffDensityResolver;
import com.xjm.i1.core.struct.location.MinDataPointMap;
import com.xjm.i1.core.struct.location.Point;
import com.xjm.i1.entity.ColorDiffDensityArea;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * i1原始数据中中间色差与密度解析器
 **/
public class MiddleColorDiffDensityResolver extends AbstractColorDiffDensityResolver {

    private static AreaEnum areaSign;

    private static List<MinDataPointMap> pointMaps;

    // 构建数据映射
    static {
        areaSign = AreaEnum.MIDDLE;
        pointMaps = new LinkedList<MinDataPointMap>();
        MinDensityEnum[] values = MinDensityEnum.getMinDensityEnumOrdered();
        int colorLen = ColorEnum.getMinColorEnumOrdered().length;
        ColorEnum[] colorEnumOrdered = ColorEnum.getMinColorEnumOrdered();
        String[] colorDiffValOrder = ColorDiffDensityArea.getColorDiffDensityValOrder();

        // 密度按颜色顺序对应的y轴坐标
        int [] densityPointY = {4, 5, 6, 7, 7, 5, 5};

        // 第一层：需要收集的百分比密度
        for (int i=0; i<values.length; i++) {

            // 第二层：小层数据的颜色种类
            for (int c=0; c<colorLen; c++) {
                List<Point> points = new ArrayList<Point>();

                // 第三层：颜差数据每个颜色获取3个
                for (int y=0; y<3; y++) {
                    points.add(new Point(i*7+c, y+1, colorDiffValOrder[y]));
                }

                // 密度数据
                points.add(new Point(i*7+c, densityPointY[c], colorDiffValOrder[3]));
                pointMaps.add(new MinDataPointMap(colorEnumOrdered[c], values[i], points));
            }
        }

    }

    public MiddleColorDiffDensityResolver() {
        super(areaSign, pointMaps);
    }
}
